package com.example.springbootrabbitmq.demo1;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class UserSender {

    @Autowired
    private AmqpTemplate rabbitTemplate;

    public void send() {
        int size = 1000;
        for (int i = 0; i < size; i++) {
            User user = new User();
            user.setName("tang"+i);
            user.setPass("123456789");
            System.out.println("user send: " + user.getName() + "/" + user.getPass());
            rabbitTemplate.convertAndSend("userQueue", user);
        }

    }
}
